import logging

class BaseConfig(object):
    SECRET_KEY = 'time_record_91_haikou_#$#@$%^$#$'
    # 网站地址
    # SERVER_NAME = '127.0.0.1:10000'
    # 数据库
    SQLALCHEMY_DATABASE_URI = '''mysql+pymysql://root:12abABab@@@@time.91haikou.com:3306/time_record?charset=utf8mb4'''
    SQLALCHEMY_COMMIT_ON_TEARDOWN = True
    # 查看执行语句
    # SQLALCHEMY_ECHO = True
    # 上传文件地址
    UPLOAD_FOLDER = 'static/image/'
    # 电子表格存档地址
    EXCEL_FOLDER = 'static/excel/'
    ALLOWED_EXTENSIONS = set(["txt", 'pdf', 'png', 'jpg', 'jpeg', 'gif', 'doc', 'docx', 'pdf', 'zip', 'xls', 'xlsx'])
    RESTPLUS_VALIDATE = True
    LOG_LEVEL = logging.DEBUG
    # wx
    WX_APP_ID = 'wxd7ee1972ce81698e'
    WX_APP_SECRET = '808a6d32340bae61f3b6bbf0aa281dbb'
    # WX_APP_MCHID = '1513033211'
    # WX_APP_KEY = '36a8859b643c497665a2ae24d201fa58'
    # 根据code获取微信access_token, open_id
    WX_GET_ACCESS_TOKEN_URL = "https://api.weixin.qq.com/sns/jscode2session?appid=%s&secret=%s" \
                              "&js_code=%s&grant_type=authorization_code"
    # 根据open_id, access_token获取用户信息
    WX_GET_ID_URL = "https://api.weixin.qq.com/sns/userinfo?access_token=%s&openid=%s"
    # 微信分享redirect_url
    WX_REDIRECT_URL = r'http://dev.api.haizb.cn/h5/html/index/index.html?activity_id=%s&user_id=%s&unionid=%s'
    WX_REDIRECT_URL_EX = 'http://dev.api.haizb.cn/h5/html/index/index.html?activity_id=%s&user_id=%s&unionid=%s'
    WX_UNION_ID_URL = "https://api.weixin.qq.com/sns/userinfo?access_token=%s&openid=%s&lang=zh_CN"
    WX_USER_INFO_SCOPE = "snsapi_userinfo"
    WX_JS_TOKEN_API_URL = "https://api.weixin.qq.com/cgi-bin/token?grant_type=client_credential&appid=%s&secret=%s"
    WX_JS_TICKET_API_URL = "https://api.weixin.qq.com/cgi-bin/ticket/getticket?access_token=%s&type=jsapi"

    # 跨域配置
    CORS_HEADERS = ['Content-Type', 'Authorization']
    CORS_AUTOMATIC_OPTIONS = True
    pass


class DevConfig(BaseConfig):
    DEBUG = True
    SQLALCHEMY_DATABASE_URI = '''mysql+pymysql://root:12abABab@@@dev1.haizb.cn:3306/db4_haizhibo_2?charset=utf8mb4'''


class ProductConfig(BaseConfig):
    DEBUG = False
    RTMP_PUBLISH = 'pili-publish.api.haizb.cn'
    WX_REDIRECT_URL = r'http://api.haizb.cn/h5/html/index/index.html?activity_id=%s&user_id=%s&unionid=%s'
    WX_REDIRECT_URL_EX = 'http://api.haizb.cn/h5/html/index/index.html?activity_id=%s&user_id=%s&unionid=%s'
    SQLALCHEMY_DATABASE_URI = '''mysql+pymysql://root:12abABab@@@@time.91haikou.com:3306/time_record?charset=utf8mb4'''
    HOST_URL = "http://127.0.0.1:10000/"


class ProductDebugConfig(BaseConfig):
    DEBUG = True
    SQLALCHEMY_DATABASE_URI = '''mysql+pymysql://root:12abABab@@@@time.91haikou.com:3306/time_record?charset=utf8mb4'''
    HOST_URL = "http://127.0.0.1:10000/"


class LocalConfig(BaseConfig):
    DEBUG = True
    # SERVER_NAME = '127.0.0.1:10000'
    SQLALCHEMY_DATABASE_URI = '''mysql+pymysql://root:12abABab@127.0.0.1:3306/time_record?charset=utf8mb4'''
